﻿<Controls:MetroWindow
        
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
        xmlns:Custom="http://metro.mahapps.com/winfx/xaml/shared" 
    
        x:Class="AzureMobileServiceLogViewer.MainWindow"
        Title="Azure Mobile Service Log Viewer" Height="624.321"
        xmlns:AmsvConverter="clr-namespace:AzureMobileServiceLogViewer.Controls.Converter;assembly=AzureMobileServiceLogViewer.Controls"
    
        >

    <Controls:MetroWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <BooleanToVisibilityConverter x:Key="conVisibility"/>
            <Custom:OffOnConverter x:Key="OffOnConverter"/>
            <AmsvConverter:BooleanInverter x:Key="BoolConverter"/>
            <AmsvConverter:DateUTCToLocalConverter x:Key="DateUTCToLocalConverter"/>
        </ResourceDictionary>

    </Controls:MetroWindow.Resources>

    <Controls:MetroWindow.WindowCommands>
        <Controls:WindowCommands>
            <Button Content="Import Publish Settings..." x:Name="btnImportSettings" Command="{Binding OpenSettingWindows}"/>
            <Separator/>
            <Button Content="About" x:Name="HelpAbout" Command="{Binding HelpAboutCommand}" />
          
        </Controls:WindowCommands>
        
        
    </Controls:MetroWindow.WindowCommands>
    
    <Grid Margin="10">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="180"></ColumnDefinition>
            <ColumnDefinition MinWidth="120"></ColumnDefinition>
            <ColumnDefinition Width="150"></ColumnDefinition>
            <ColumnDefinition Width="250"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition MinHeight="350"></RowDefinition>
            <RowDefinition Height="40"></RowDefinition>
        </Grid.RowDefinitions>

        <Label Content="Choose you Subscription :" Grid.Column="0"/>


        <ComboBox  x:Name="cbxSubscription" Height="40"  HorizontalAlignment="Stretch"  VerticalContentAlignment="Center" IsEnabled="{Binding LoadingRing, Converter={StaticResource BoolConverter}}"
					ItemsSource="{Binding Subscriptions}"  
                    Grid.Column="1" Grid.ColumnSpan="3"    VerticalAlignment="Top"    >
            
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Subscription Name : " FontWeight="Bold"/>
                            <TextBlock Text="{Binding Name}"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">

                            <TextBlock Text="Subscription Id : " FontWeight="Bold"/>
                            <TextBlock Text="{Binding Id}"/>
                        </StackPanel>

                        <Line/>
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>

        </ComboBox>



        <Label Content="Service Name : " VerticalAlignment="Top"  Grid.Row="1" Grid.ColumnSpan="2" Height="30"/>
        <ComboBox VerticalAlignment="Top" HorizontalAlignment="Stretch" VerticalContentAlignment="Center"
			x:Name="cbxMobileServiceName" Grid.Row="1" Grid.Column="1" IsEnabled="{Binding LoadingRing, Converter={StaticResource BoolConverter}}"
			ItemsSource="{Binding MobileServiceList}"  Height="30"/>
        <Button Content="Load" HorizontalAlignment="Center"  VerticalAlignment="Top" Width="75" 
			Command="{Binding LoadServiceCommand}"   Grid.Row="1" Grid.Column="2"
                IsEnabled="{Binding IsChecked, ElementName=AutoRefreshButton,Converter={StaticResource BoolConverter}}" Height="30"/>
        <Controls:ToggleSwitch x:Name="AutoRefreshButton"  Grid.Row="1" Grid.Column="3"
			IsChecked="{Binding AutoRefresh}" Content="AutoRefresh"/>


        <Label Content="Date Filter : "  Grid.Row="2" />
        <DatePicker x:Name="DatePicker" Controls:TextboxHelper.Watermark="Filter by Date" Grid.Row="2" Grid.Column="1" Height="30" 
                    VerticalContentAlignment="Center"
						 IsEnabled="{Binding EnableFilter.EnableDate}"  
                    
                    HorizontalAlignment="Left" Width="150" VerticalAlignment="Top" />

        <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="2">
            <Label Content="Type Filter" VerticalAlignment="Center"/>
            <ComboBox x:Name="LogTypeComboBox" Height="30" 
                  Width="80"  SelectedIndex="0">
                <ComboBoxItem>All</ComboBoxItem>
                <ComboBoxItem>Information</ComboBoxItem>
                <ComboBoxItem>Warning</ComboBoxItem>
                <ComboBoxItem>Error</ComboBoxItem>
            </ComboBox>

        </StackPanel>
        
        <Label HorizontalAlignment="Left"  Content="Message " VerticalAlignment="Top" Grid.Row="3" Height="30"/>
        <TextBox VerticalAlignment="Top" VerticalContentAlignment="Center"
						Controls:TextboxHelper.Watermark="Enter a string to filter the list"
						x:Name="tbMessage"  Grid.Row="3" Grid.Column="1"  Height="30" />
        <StackPanel  Grid.Row="3" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Center">
            <Button x:Name="btnSearch" Content="Search" HorizontalAlignment="Left" 
						IsEnabled="{Binding EnableFilter.EnableSearch}"
						VerticalAlignment="Top" Width="60"  Height="30" />
            <Separator/>
            <Button x:Name="btnReset" Content="Reset"   Grid.Row="3" Grid.Column="2"
						IsEnabled="{Binding EnableFilter.EnableReset}"
						HorizontalAlignment="Left"  VerticalAlignment="Top" Width="60"  Height="30" />
        </StackPanel>

        <StackPanel Grid.Row="3" Grid.Column="3" Orientation="Horizontal">
            <Label Content="Rows : "  VerticalAlignment="Top"   Height="30" />
            <Label Content="{Binding LogView.Count}"  VerticalAlignment="Top" Height="30" />
        </StackPanel>
       

         <DataGrid Grid.Row="4" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" PresentationTraceSources.TraceLevel="High"
					ItemsSource="{Binding LogView}" x:Name="dataGridLogs" AutoGenerateColumns="False" 
                   CanUserAddRows="False"
                   CanUserDeleteRows="False"
                   IsReadOnly="True"
                   IsEnabled="{Binding LoadingRing,Converter={StaticResource BoolConverter}}"
                   >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding source}"  Header="Source"/>
                <DataGridTextColumn Binding="{Binding type}"  Header="Type"/>
                <DataGridTextColumn Binding="{Binding timeCreated, Converter={StaticResource DateUTCToLocalConverter}}"  Header="TimeCreated"/>
                <DataGridTextColumn Binding="{Binding message}"  Header="Message" Width="*"/>
            </DataGrid.Columns>
        </DataGrid>
        <Controls:ProgressRing IsActive="{Binding LoadingRing}" Grid.Row="4" Height="60" Width="60" Grid.ColumnSpan="4"/>

        
        <DockPanel Grid.Row="5" Grid.ColumnSpan="4" Margin="0,10,0,0" HorizontalAlignment="Stretch">
            <Controls:TransitioningContentControl x:Name="transitioning"
                                                  HorizontalAlignment="Stretch" 
                                                  VerticalAlignment="Top" Height="30"
                                                  Transition="UpTransition" 
                                                  Content="{Binding Message}"/>
            <StackPanel DockPanel.Dock="Right" Orientation="Vertical">
                <TextBlock  Text="Next Refresh Date : " />
                <TextBlock Name="RefreshDate" Text="{Binding NextRefreshDate}"/>
            </StackPanel>
            
            <StackPanel Visibility="{Binding LoadingRingMessage, Converter={StaticResource conVisibility}}"
                       DockPanel.Dock="Right" >
                <Controls:ProgressIndicator Width="100" 
                                                        Height="10"
                                                       HorizontalAlignment="Right"
                                                        ProgressColour="DeepSkyBlue"  />
            </StackPanel>
            
        </DockPanel>
        




        <!--<ListView HorizontalAlignment="Left" Height="25" Margin="106,10,0,0" VerticalAlignment="Top" Width="475"
                  ItemsSource="{Binding Subscriptions}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Id}"/>
                        <TextBlock Text="{Binding Name}"/>
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
                
        </ListView>-->
    </Grid>
</Controls:MetroWindow>
